#include "StateMachineState.h"

FrontLampStateManagement g_FrontNewState = {
    .usageModeState_                = UsageModeState_Init,
    .normalState_                   = NormalStateLeFrntTurnLamp_Invaild,
    .ribbonLobeamCtrlState_         = RibbonLobeamCtrlState_Invaild,
    .ribbonLobeamEffectShowState_   = RibbonLobeamEffectShowState_Invaild,
};

FrontLampStateManagement g_FrontLastState = {
    .usageModeState_                = UsageModeState_Init,
    .normalState_                   = NormalStateLeFrntTurnLamp_Invaild,
    .ribbonLobeamCtrlState_         = RibbonLobeamCtrlState_Invaild,
    .ribbonLobeamEffectShowState_   = RibbonLobeamEffectShowState_Invaild,
};

TurnLampStateManagement g_TurnLastState = {
    .usageModeState_                = UsageModeState_Init,
    .normalState_                   = NormalStateLeFrntTurnLamp_Invaild,
    .ribbonLeTurnLampState_         = RibbonLeTurnLamp_Invaild,
    .ribbonPosnCtrlState_           = RibbonPosnCtrlState_Invaild,
    .ribbonPosnEffectShowState_     = RibbonPosnEffectShowState_Invaild,
};

TurnLampStateManagement g_TurnNewState = {
    .usageModeState_                = UsageModeState_Init,
    .normalState_                   = NormalStateLeFrntTurnLamp_Invaild,
    .ribbonLeTurnLampState_         = RibbonLeTurnLamp_Invaild,
    .ribbonPosnCtrlState_           = RibbonPosnCtrlState_Invaild,
    .ribbonPosnEffectShowState_     = RibbonPosnEffectShowState_Invaild,
};

bool waitLastStateExitFinish(StateMachineBase* sm)
{
    if(sm->waitExitCount_)
    {
        sm->waitExitCount_--;
    }
    return sm->waitExitCount_ == 0;
}

void resetWaitExitCount(StateMachineBase* sm, uint8_t maxCount)
{
    sm->waitExitCount_ = maxCount;
}

void UpdateUsageModeState(UsageModeState newState, UsageModeState* targetState)
{
    *targetState = newState;
}

void UpdateNormalState(NormalState newState, NormalState* targetState)
{
    *targetState = newState;
}

void UpdateRibbonLeTurnLampState(RibbonLeTurnLampState newState, RibbonLeTurnLampState* targetState)
{
    *targetState = newState;
}

void UpdateRibbonPosnCtrlState(RibbonPosnCtrlState newState, RibbonPosnCtrlState* targetState)
{
    *targetState = newState;
}

void UpdateRibbonPosnEffectShowState(RibbonPosnEffectShowState newState, RibbonPosnEffectShowState* targetState)
{
    *targetState = newState;
}

void UpdateRibbonLobeamCtrlState(RibbonLobeamCtrlState newState, RibbonLobeamCtrlState* targetState)
{
    *targetState = newState;
}

void UpdateRibbonLobeamEffectShowState(RibbonLobeamEffectShowState newState, RibbonLobeamEffectShowState* targetState)
{
    *targetState = newState;
}


